package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportContingPlanFlowDto;
import com.yqg.protection.entity.ContingPlanFlow;
import com.yqg.protection.mapper.ContingPlanFlowMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/16 11:26
 * description:
 */
@Component
public class ContingPlanFlowListener extends AnalysisEventListener<ImportContingPlanFlowDto> {

    @Autowired
    private ContingPlanFlowMapper contingPlanFlowMapper;

    @Override
    public void invoke(ImportContingPlanFlowDto importContingPlanFlowDto, AnalysisContext analysisContext) {
        ContingPlanFlow contingPlanFlow = new ContingPlanFlow();
        BeanUtil.copyProperties(importContingPlanFlowDto, contingPlanFlow, true);
        contingPlanFlow.setIsDelete(0);
        contingPlanFlowMapper.insert(contingPlanFlow);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
